<?php

namespace api\modules\v1\controllers\marketing;

use Yii;
use api\controllers\OnAuthController;
use common\models\marketing\ClinicAssess;
use common\helpers\CommonHelper;

/**
 * Class ClinicAssessController
 * @package api\modules\v1\controllers\marketing
 */
class ClinicAssessController extends OnAuthController
{
    /**
     * @var ClinicAssess
     */
    public $modelClass = ClinicAssess::class;

    /**
     * @api {get} /v1/marketing/clinic-assess/index 诊疗评估列表
     * @apiName index
     * @apiGroup ClinicAssess
     */
    public function actionIndexClinicAssess()
    {
        $projectId = $this->projectId;

        // 查询结果
        $data = Yii::$app->services->marketingClinicAssess->getList($projectId);

        return $data;
    }

    /**
     * @api {post} /v1/marketing/clinic_assess/create 新增诊疗评估
     * @apiName create
     * @apiGroup ClinicAssess
     *
     * @apiParam {String} name              诊疗评估名称
     * @apiParam {Number} status            【1启用、0停用】
     */
    public function actionCreateClinicAssess()
    {
        $params = Yii::$app->request->post();
        $params['member_id'] = Yii::$app->user->identity->member_id;
        $params['project_id'] = $this->projectId;

        return Yii::$app->services->marketingClinicAssess->create($params);
    }

    /**
     * @api {post} /v1/marketing/clinic_assess/update 编辑诊疗评估
     * @apiName update
     * @apiGroup ClinicAssess
     *
     * @apiParam {Number} id                诊疗评估ID
     * @apiParam {Number} status            状态【0停用 1启用】
     */
    public function actionUpdateClinicAssess()
    {
        $params = Yii::$app->request->post();
        $params['member_id'] = Yii::$app->user->identity->member_id;
        $params['project_id'] = $this->projectId;
        return Yii::$app->services->marketingClinicAssess->update($params);
    }


    /**
     * @api {post} /v1/marketing/clinic_assess/update-status 编辑诊疗评估的状态
     * @apiName update-status
     * @apiGroup ClinicAssess
     *
     * @apiParam {Number} id                诊疗评估ID
     * @apiParam {Number} status            状态【0停用 1启用】
     */
    public function actionUpdateClinicAssessStatus()
    {
        $id = Yii::$app->request->post('id');
        $status = Yii::$app->request->post('status');

        return Yii::$app->services->marketingClinicAssess->updateStatus($id, $status);
    }

    /**
     * @api {post} /v1/marketing/clinic_assess/delete 删除诊疗评估
     * @apiName delete
     * @apiGroup ClinicAssess
     *
     * @apiParam {Number} id                诊疗评估ID
     */
    public function actionDeleteClinicAssess()
    {
        $id = Yii::$app->request->post('id');

        return Yii::$app->services->marketingClinicAssess->delete($id);
    }

}